var us = ""; 
var pw = ""; 
var srv = "";

function logea()
{
    //alert("Entra al logea");
     var divTrans = document.createElement("div");
    divTrans.setAttribute("id", "divTrans");
    divTrans.setAttribute("class", "fondoPopUp");

    var login = document.createElement("div");
    login.setAttribute("id", "login");
    login.setAttribute("class", "popupWrapper");

    var divHead = document.createElement("div");
    divHead.setAttribute("class", "divHead");

    var title = document.createElement("div");
    title.setAttribute("class", "divHead1");

    var span = document.createElement("p");
    span.setAttribute("id", "spanp");
    span.innerHTML = "<b>Ingresar información de la base de datos</b>";
    title.appendChild(span);
    divHead.appendChild(title);

    var close = document.createElement("div");
    close.setAttribute("class", "divHead2");
    var imgclose = document.createElement("img");
    imgclose.setAttribute("src", "imagenes/close.png");
    imgclose.setAttribute("id", "imgClose");
    imgclose.setAttribute("class", "closeWin");
    imgclose.setAttribute("onclick", "hdte(event)");
    close.appendChild(imgclose);
    divHead.appendChild(close);

    login.appendChild(divHead);

    var line = document.createElement("hr");
    login.appendChild(line);

    var divPrin = document.createElement("div");
    divPrin.setAttribute("id", "loginDivPrin");

    var formLog = document.createElement("div");
    formLog.setAttribute("id", "formLog");
    formLog.setAttribute("method", "post");

    var form = document.createElement("form");
    form.setAttribute("id", "formLogin");

/////////////////////////////////////////////////////////////////////

    var div1 = document.createElement("div");
    div1.setAttribute("class", "loginBody");

    var div2 = document.createElement("div");
    div2.setAttribute("class", "loginBody");

    var div3 = document.createElement("div");
    div3.setAttribute("class", "loginBody");

    var span1 = document.createElement("p");
    span1.setAttribute("class", "span");
    span1.setAttribute("id", "spanNombUs");
    span1.innerHTML = "Usuario";
    div1.appendChild(span1);

    var span3 = document.createElement("p");
    span3.setAttribute("class", "span");
    span3.setAttribute("id", "spanContUs");
    span3.innerHTML = "Contraseña";
    div1.appendChild(span3);
    
    var span4 = document.createElement("p");
    span4.setAttribute("class", "span");
    span4.setAttribute("id", "spanServBa");
    span4.innerHTML = "Servicio";
    div1.appendChild(span4);

     var select = document.createElement("select");
     select.setAttribute("id","userSelect");
         
     var option1 = document.createElement("option");
     option1.innerHTML = "sys as sysdba";
     var option2 = document.createElement("option");
     option2.innerHTML = "system as sysdba";
     
     select.appendChild(option1);
     select.appendChild(option2);
//    var input = document.createElement("input");
//    input.setAttribute("id", "user");
//    input.setAttribute("placeholder", "Usuario de base");
//    input.setAttribute("class", "inputsL");
//    input.setAttribute("name", "user");
//    input.setAttribute("tabindex", "1");
    div2.appendChild(select); 
    
  
     

    var input2 = document.createElement("input");
    input2.setAttribute("id", "pw");
    input2.setAttribute("type", "password");
    input2.setAttribute("placeholder", "Contraseña de usuario");
    input2.setAttribute("value", "root");
    input2.setAttribute("class", "inputsL");
    input2.setAttribute("name", "pw");
    input2.setAttribute("tabindex", "2");
    div2.appendChild(input2);
    
    var input2 = document.createElement("input");
    input2.setAttribute("id", "srv");
    input2.setAttribute("placeholder", "Nombre de Servicio"); 
    input2.setAttribute("value", "orcl");
    input2.setAttribute("class", "inputsL");
    input2.setAttribute("name", "srvc");
    input2.setAttribute("tabindex", "3");
    div2.appendChild(input2);

    form.appendChild(div1);
    form.appendChild(div2);
    form.appendChild(div3);

/////////////////////////////////////////////////////////////////////
    formLog.appendChild(form);
    divPrin.appendChild(formLog);
    creaBotonesSolicitud1(form);

    login.appendChild(divPrin);

    document.getElementById("divPrincipal").appendChild(divTrans);
    document.getElementById("divPrincipal").appendChild(login);

    var div = $('#login');
    div.css({
        'left': ($(window).width() / 2 - $(div).width() / 2) + 'px',
        'top': ($(window).height() / 2 - $(div).height() / 2) + 'px'
     });

    //asignarListener();

    $("#login").fadeIn();
}

function creaBotonesSolicitud1(div)
{
    var bot = document.createElement("input");
    bot.value = "Siguiente";
    bot.setAttribute("class", "botL");
    bot.setAttribute("tabindex", "3"); 
    bot.setAttribute("onclick","delog()");
    bot.id = "botLA";
    bot.name = "botLA";
    div.appendChild(bot);
} 

function delog()
{
    us = getSelectedText("userSelect");
    pw = $("#pw").val();
    srv = $("#srv").val();  
    $("#divTrans").hide();
    $("#login").hide();  
    $("#divInit").show(); 
}